﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ECommerce.BLL.Product;
using ECommerce.Model.Product;
using ECommerce.Common;

namespace ECommerce.Web.Site
{
    public partial class MemberFavorite : SitePage
    {
        private ECProductBO Product
        {
            get
            {
                return ECProductBO.Instance<ECProductBO>();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            base.CheckLogin();
            if (!IsPostBack)
            {
                BindView();
            }
        }

        private void BindView()
        {
            List<ECProductInfo> list = Product.GetFavoriteList(SiteSession.MemberID);
            rpt.DataSource = list;
            rpt.DataBind();
        }

        protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                int id = int.Parse(e.CommandArgument.ToString());
                this.Product.DeleteFavorite(SiteSession.MemberID, id);
                BindView();
                
            }
        }
    }
}